home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 8: LINUX Games / Linux Cubed Series 8 - LINUX Games.iso / games / muds / lpmud312.tar / lpmud312 / simul_efun.c < prev    next >
C/C++ Source or Header  |  1992-01-11  |  2KB  |  76 lines

  1. #include <stdio.h>
  2. #include <string.h>
  3.  
  4. #include "lint.h"
  5. #include "interpret.h"
  6. #include "object.h"
  7. #include "exec.h"
  8.  
  9. static struct function *simul_efunp = 0;
  10. static int num_simul_efun;
  11.  
  12. /* Don't release this pointer ever. It is used elsewhere. */
  13. static char *simul_efun_file_name;
  14.  
  15. /*
  16.  * If there is a simul_efun file, then take care of it and extract all
  17.  * information we need.
  18.  */
  19. void get_simul_efun(svp)
  20.     struct svalue *svp;
  21. {
  22.     struct object *ob;
  23.     struct function *funp;
  24.     int i;
  25.  
  26.     if (svp == 0 || (svp->type == T_NUMBER && svp->u.number == 0)) {
  27.     fprintf(stderr, "No simul_efun\n");
  28.     return;
  29.     }
  30.     simul_efun_file_name = make_shared_string(svp->u.string);
  31.  
  32.     ob = find_object2(simul_efun_file_name);
  33.  
  34.     if (ob == 0) {
  35.     fprintf(stderr, "The simul_efun file %s was not loaded.\n",
  36.         simul_efun_file_name);
  37.     fprintf(stderr, "The function get_simul_efun in master.c must load it.\n");
  38.     exit(1);
  39.     }
  40.     num_simul_efun = ob->prog->num_functions;
  41.     if (num_simul_efun == 0)
  42.     return;
  43.     funp = ob->prog->functions;
  44.     simul_efunp = (struct function *)
  45.     malloc(sizeof (struct function) * num_simul_efun);
  46.     for (i=0; i < ob->prog->num_functions; i++) {
  47.     simul_efunp[i].name = make_shared_string(funp[i].name);
  48.     simul_efunp[i].flags = funp[i].flags;
  49.     simul_efunp[i].num_arg = funp[i].num_arg;
  50.     simul_efunp[i].type = funp[i].type & TYPE_MOD_MASK;
  51.     }
  52. }
  53.  
  54. /*
  55.  * Test if 'name' is a simul_efun. The string pointer MUST be a pointer to
  56.  * a shared string.
  57.  */
  58. struct function *find_simul_efun(name)
  59.     char *name;
  60. {
  61.     int i;
  62.     for (i=0; i < num_simul_efun; i++) {
  63.     if (name == simul_efunp[i].name)
  64.         return &simul_efunp[i];
  65.     }
  66.     return 0;
  67. }
  68.  
  69. char *query_simul_efun_file_name() {
  70. #ifdef DEBUG
  71.     if (simul_efunp == 0)
  72.     fatal("query_simlu_efun_file_name called when non exists!\n");
  73. #endif
  74.     return simul_efun_file_name;
  75. }
  76.